<?php

namespace app\command;

use think\console\Command;
use think\console\Input;
use think\console\Output;
use think\console\input\Argument;
use app\command\tasks\monthBillTask;
use app\command\tasks\ElectricOperateRunTask;
use app\command\tasks\EnergyDayFreezeReadingTask;

class Task extends Command
{

    protected function configure()
    {
        $this->setName('task')
            ->addArgument('option', Argument::OPTIONAL, "task run")
            ->setDescription('task run');
    }


    protected function execute(Input $input, Output $output)
    {
        $name = trim($input->getArgument('option'));

        switch ($name) {
            case 'generate_bill': ## 检测租赁生成账单   每日晚上 5 点执行
                /** @var monthBillTask $task */
                $task = app()->make(monthBillTask::class);
                $task->execute();

                $output->writeln('Success!');
                break;
            case 'electric_operate_run': ## 电表操作运行  任务监听
                /** @var ElectricOperateRunTask $task */
                $task = app()->make(ElectricOperateRunTask::class);
                $task->execute();

                $output->writeln('Success!');
                break;

            case 'energy_day_task': ## 水电气日冻结  每小时, 第30分钟 执行
                /** @var EnergyDayFreezeReadingTask $task */
                $task = app()->make(EnergyDayFreezeReadingTask::class);
                $task->execute();

                $output->writeln('Success!');
                break;

            case 'contract_rent_inc': # 租赁租金递增
                /** @var ContractRentIncTask $task */
                $task = app()->make(ContractRentIncTask::class);
                $task->execute();

                $output->writeln('Success!');
                break;
            case 'contract_expired_check': # 租赁过期
                /** @var ContractExpireTask $task */
                $task = app()->make(ContractExpireTask::class);
                $task->execute();

                $output->writeln('Success!');
                break;

            case 'contract_expired_check': # 合同退租
                /** @var ContractExpireTask $task */
                $task = app()->make(ContractExpireTask::class);
                $task->execute();

                $output->writeln('Success!');
                break;
        }
    }
}